package com.bzkj.web.controller.warehouse;

import com.bzkj.basicinfo.domain.ncc.StoUnit;
import com.bzkj.basicinfo.domain.wms.vo.*;
import com.bzkj.basicinfo.service.ncc.StoUnitService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import com.bzkj.common.utils.poi.CsvExportUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;

/**
 * 货位信息 业务处理
 */
@Api(tags = "货位管理")
@RestController
@RequestMapping("/stoUnit")
public class StoUnitController extends BaseController
{

    @Autowired
    private StoUnitService stoUnitService; // 注入货位服务

    /**
     * @param stoUnit 新货位信息
     * @return AjaxResult 返回添加结果信息
     * @method addStoUnit
     * @description 添加新的货位
     */
    @PreAuthorize("@ss.hasPermi('index:position:add')")
    @ApiOperation("添加新的货位")
    @PostMapping
    @LogC(title = "新的货位", businessType = BusinessType.INSERT, pkFieldNames = "sto_unit_id",
            tableNames = "basic_sto_unit",
            content = "'仓库：'+#stoUnit.stoId+';库区:'+#stoUnit.stoAreaId+'货位类型：'+#stoUnit.def1"
    )
    public AjaxResult addStoUnit(@RequestBody StoUnit stoUnit)
    {
        return stoUnitService.addStoUnit(stoUnit); // 调用服务层添加货位

    }

    /**
     * @param stoUnit 更新后的货位信息
     * @return AjaxResult 返回更新结果信息
     * @method updateStoUnit
     * @description 更新货位信息
     */
    @PreAuthorize("@ss.hasPermi('index:position:edit')")
    @ApiOperation("更新货位信息")
    @PutMapping
    public AjaxResult updateStoUnit(@RequestBody StoUnit stoUnit)
    {
        int result = stoUnitService.updateStoUnit(stoUnit); // 调用服务层更新货位
        if(result > 0) {
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
    }

    /**
     * @param stoUnitId 货位ID
     * @return AjaxResult 返回货位信息
     * @method getStoUnitById
     * @description 根据ID获取货位信息
     */
    @ApiOperation("根据stoUnitId获取货位信息")
    @GetMapping("/{stoUnitId}")
    public AjaxResult getStoUnitById(@PathVariable String stoUnitId)
    {
        StoUnit stoUnit = stoUnitService.getStoUnitById(stoUnitId); // 根据ID查询货位
        if(stoUnit != null) {
            return AjaxResult.success(stoUnit); // 返回成功并包含货位数据
        } else {
            return AjaxResult.error("货位未找到");
        }
    }

    /**
     * @param areaId 库区ID
     * @return AjaxResult 返回货位列表
     * @method getStoUnitsByAreaId
     * @description 根据库区ID获取所有货位
     */
    @ApiOperation("根据库区areaId获取该库区下所有货位")
    @GetMapping("/area/{areaId}")
    public AjaxResult getStoUnitsByAreaId(@PathVariable String areaId)
    {
        List<StoUnit> stoUnits = stoUnitService.getStoUnitsByAreaId(areaId); // 使用 String 类型的 areaId
        if(stoUnits.isEmpty()) {
            return AjaxResult.error("该库区没有货位信息");
        }
        return AjaxResult.success(stoUnits); // 返回成功并包含货位列表
    }

    /**
     * @param stoUnit 查询条件（用于分页和筛选）
     * @return TableDataInfo 返回分页后的货位列表
     * @method getAllStoUnits
     * @description 获取所有货位信息，支持分页
     */
    @ApiOperation("获取所有货位信息")
    @GetMapping
    public TableDataInfo getAllStoUnits(StoUnit stoUnit)
    {
        // 开始分页
        startPage(); // 获取分页信息

        // 查询货位列表
        List<StoUnit> stoUnits = stoUnitService.getAllStoUnits(stoUnit);

        // 返回分页后的数据
        return getDataTable(stoUnits);
    }

    /**
     * @param stoUnitId 货位ID
     * @return AjaxResult 返回删除结果信息
     * @method deleteStoUnit
     * @description 根据ID删除货位
     */
    @ApiOperation("根据stoUnitId删除货位")
    @DeleteMapping("/{stoUnitId}")
    public AjaxResult deleteStoUnit(@PathVariable String stoUnitId)
    {
        int result = stoUnitService.deleteStoUnit(stoUnitId); // 调用服务层删除货位
        if(result > 0) {
            return success("删除货位成功");
        } else {
            return error("删除货位失败");
        }

    }


    @PreAuthorize("@ss.hasPermi('index:wareHouse:list')")
    @GetMapping("/all")
    public R queryStoUnit(@RequestParam("stoAreaId") String stoAreaId)
    {
        //        try {
        //            try {
        return R.ok(stoUnitService.queryStoUnit(stoAreaId));
        //            } catch(Exception e) {
        //                return R.fail("查询失败");
        //            }
        //        } catch(Exception e) {
        //            e.printStackTrace();
        //            return R.fail("查询失败");
        //        }
    }

    /**
     * 获取货位信息
     * @param stoAreaCode
     * @param stoUnitCode
     * @return
     */
    @GetMapping("queryStoUnitInfo")
    public R queryStoUnitInfo(@RequestParam String stoAreaCode, @RequestParam(required = false,defaultValue = "") String stoUnitCode)
    {
        return stoUnitService.queryStoUnitInfo(stoAreaCode, stoUnitCode);
    }


    @GetMapping("/find")
    public HashMap<String, Object> queryStoUnit(String sto_area_code, String sto_unit_code)
    {
        HashMap<String, Object> response = new HashMap<>();
        if(sto_area_code == null && sto_unit_code == null) {
            response.put("success", false);
            response.put("data", null);
            response.put("code", "400");
            response.put("message", "缺少必要参数");
            return response;
        }

        if(sto_area_code == null) {
            sto_area_code = "";
        }
        if(sto_unit_code == null) {
            sto_unit_code = "";
        }

        //        调用函数直接返回
        List<HashMap<String, Object>> hashMaps = null;
        try {
            try {
                hashMaps = stoUnitService.queryStoUnit(sto_area_code, sto_unit_code);
                response.put("success", true);
                response.put("data", hashMaps);
                response.put("code", "200");
                response.put("message", "货位查询成功");
                response.put("errorStack", null);
                response.put("totalnum", hashMaps.size());
            } catch(Exception e) {
                response.put("success", false);
                response.put("data", null);
                response.put("code", "444");
                response.put("message", "货位查询异常");
                response.put("errorStack", e);
                response.put("totalnum", 0);
            }
        } catch(Exception e) {
            e.printStackTrace();
        }

        return response;
    }


    @GetMapping("/queryGood")
    public HashMap<String, Object> queryGood(String name, String materialspec, String vbatchcode, String pkMaterial)
    {
        System.out.println("----------------");
        System.out.println(name + "," + materialspec + "," + vbatchcode + "," + pkMaterial);
        System.out.println("----------------");
        HashMap<String, Object> response = new HashMap<>();
        // 数据列表
        //        List<HashMap<String, Object>> dataList = new ArrayList<>();
        List<HashMap<String, Object>> hashMaps = stoUnitService.queryGoods(name, materialspec, vbatchcode, pkMaterial);

        // 将数据列表放入响应
        response.put("success", true);
        response.put("data", hashMaps);
        // 添加其他字段
        response.put("code", "1000000000");
        response.put("message", "商品查询成功");
        response.put("errorStack", null);
        return response;
    }

    /**
     * 获取所有的货位编码（只截取到货位层数）
     *
     * @return
     */
    @GetMapping("/getAllStoUnitCode")
    public R getAllStoUnitCode(@RequestParam(value = "stoId",required = false) String stoId,@RequestParam(value = "stoAreaId",required = false) String stoAreaId) {
        return stoUnitService.getAllStorageNumber(stoId,stoAreaId);
    }
    /**
     * @param stoUnit 新货位信息
     * @return AjaxResult 返回添加结果信息
     * @method `addStoUnitStorage`
     * @description 添加新的货位(单独追加货位）
     */
    @PreAuthorize("@ss.hasPermi('index:position:add')")
    @ApiOperation("添加新的货位")
    @PostMapping("addStoUnitStorage")
//    @LogC(title = "货位", businessType = BusinessType.INSERT, pkFieldNames = "sto_unit_id",
//            tableNames = "basic_sto_unit", content = "'仓库：'+#stoUnit.stoId+';库区:'+#stoUnit.stoAreaId+',续增货位编码：'+#stoUnit.stoUnitCode"
//    )
    public AjaxResult addStoUnitStorage(@RequestBody StoUnit stoUnit)
    {
        return stoUnitService.addStoUnitStorage(stoUnit);
    }

    /**
     * 货位统计报表数据
     *
     * @return
     */
    //    @PreAuthorize("@ss.hasPermi('basic:bankStat:list')")
    @GetMapping("/wmsReportUnitStatistic")
    public R wmsReportUnitStatistic(
            @RequestParam(required = false, defaultValue = "") String wareHouseId,
            @RequestParam(required = false, defaultValue = "") String wareHouseValue,
            @RequestParam(required = false, defaultValue = "") String wareHouseTypeID,
            @RequestParam(required = false, defaultValue = "") String wareHouseTypeIdValue,
            @RequestParam(required = false, defaultValue = "") String unitTypeId,
            @RequestParam(required = false, defaultValue = "") String unitTypeIdValue,
            @RequestParam(required = false, defaultValue = "") String sType) {
        return stoUnitService.wmsReportUnitStatistic(wareHouseId, wareHouseValue, wareHouseTypeID, wareHouseTypeIdValue, unitTypeId, unitTypeIdValue, sType);
    }

    /**
     * 基础报表
     * @return
     */
    @GetMapping("/wmsReportBasicStatistic")
    public R wmsReportBasicStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum,Integer pageSize
    ) {
        return stoUnitService.wmsReportBasicStatistic(skuID, skuClassId, wareHouseID, openBatchNo,
                batchNo,batchNoValue,beginDate,endDate,turnoverRateMinVal,turnoverRateMaxVal,
                turnoverDay,turnoverDayValue,skuRateMinVal,skuRateMaxVal,pageNum,pageSize);
    }
    @GetMapping("/wmsReportTurnoverRate")
    public R wmsReportTurnoverRate(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum,Integer pageSize
    ) {
        return stoUnitService.turnoverRate(skuID, skuClassId, wareHouseID, openBatchNo,
                batchNo,batchNoValue,beginDate,endDate,turnoverRateMinVal,turnoverRateMaxVal,
                turnoverDay,turnoverDayValue,skuRateMinVal,skuRateMaxVal);
    }

    /**
     * 呆滞物料
     */
    @GetMapping("/wmsReportSluggishStatistic")
    public R wmsReportSluggishStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String sluggishBegin,
            @RequestParam(required = false, defaultValue = "") String sluggishEnd,
            Integer pageNum, Integer pageSize
    ) {
        return stoUnitService.wmsReportSluggishStatistic(skuID, skuClassId, wareHouseID,
                batchNo, batchNoValue, sluggishBegin, sluggishEnd,pageNum,pageSize);
    }

    @ApiOperation("呆滞物料导出excel")
    @LogC(title = "不合格品台账", businessType = BusinessType.EXPORT)
    @PostMapping("/exportReportSluggishStatistic")
    public AjaxResult exportReportSluggishStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String sluggishBegin,
            @RequestParam(required = false, defaultValue = "") String sluggishEnd,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
    ) {
        return stoUnitService.exportReportSluggishStatistic(skuID, skuClassId, wareHouseID,
                batchNo, batchNoValue, sluggishBegin, sluggishEnd, pageNum, pageSize, response);
    }

    /**
     * 不合格品报表
     *
     * @return
     */
    @GetMapping("/wmsReportUnqualifiedStatistic")
    public R wmsReportUnqualifiedStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum, Integer pageSize
            ) {
        return stoUnitService.wmsReportUnqualifiedStatistic(skuClassId,skuID,
                batchNo, batchNoValue,pageNum,pageSize);
    }
    @ApiOperation("不合格品台账导出excel")
    @LogC(title = "不合格品台账", businessType = BusinessType.EXPORT)
    @PostMapping("/exportReportUnqualifiedStatistic")
    public AjaxResult exportReportUnqualifiedStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportReportUnqualifiedStatistic(skuClassId,skuID,
                batchNo, batchNoValue,pageNum,pageSize,response);
    }
    @ApiOperation("不合格品台账导出pdf")
    @LogC(title = "不合格品台账", businessType = BusinessType.EXPORTPDF)
    @PostMapping("/exportPdfReportUnqualifiedStatistic")
    public AjaxResult exportPdfReportUnqualifiedStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportPdfReportUnqualifiedStatistic(skuClassId,skuID,
                batchNo, batchNoValue,pageNum,pageSize,response);
    }
    @ApiOperation("不合格品台账导出csv")
    @LogC(title = "不合格品台账", businessType = BusinessType.EXPORTCSV)
    @PostMapping("/exportCsvReportUnqualifiedStatistic")
    public AjaxResult exportCsvReportUnqualifiedStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        List<ExportReportUnqualifiedVo> vos = stoUnitService.exportCsvReportUnqualifiedStatistic(skuClassId, skuID,
                batchNo, batchNoValue, pageNum, pageSize, response);
        try {
            CsvExportUtils.exportToWeb(response, "不合格品台账.csv", vos);
            return AjaxResult.success("导出成功");
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("导出失败");
        }
    }

    /**
     * 发运记录报表
     *
     * @return
     */
    @GetMapping("/wmsReportDeliveryStatistic")
    public R wmsReportDeliveryStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String shippingMethod,
            @RequestParam(required = false, defaultValue = "") String customerID,
            @RequestParam(required = false, defaultValue = "") String vbillsCode,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String wareHouseOutBills,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            Integer pageNum, Integer pageSize
            ) {
        return stoUnitService.wmsReportDeliveryStatistic(skuID,wareHouseID,shippingMethod,customerID,vbillsCode,
                batchNo, batchNoValue,wareHouseOutBills,beginDate,endDate,pageNum,pageSize);
    }
    @ApiOperation("产品发运记录导出")
    @LogC(title = "产品发运记录", businessType = BusinessType.EXPORT)
    @PostMapping("/exportReportDeliveryStatistic")
    public AjaxResult exportReportDeliveryStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String shippingMethod,
            @RequestParam(required = false, defaultValue = "") String customerID,
            @RequestParam(required = false, defaultValue = "") String vbillsCode,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String wareHouseOutBills,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportReportDeliveryStatistic(skuID,wareHouseID,shippingMethod,customerID,vbillsCode,
                batchNo, batchNoValue,wareHouseOutBills,beginDate,endDate,pageNum,pageSize,response);
    }
    @ApiOperation("产品发运记录导出pdf")
    @LogC(title = "产品发运记录", businessType = BusinessType.EXPORTPDF)
    @PostMapping("/exportPdfReportDeliveryStatistic")
    public AjaxResult exportPdfReportDeliveryStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String shippingMethod,
            @RequestParam(required = false, defaultValue = "") String customerID,
            @RequestParam(required = false, defaultValue = "") String vbillsCode,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String wareHouseOutBills,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportPdfReportDeliveryStatistic(skuID,wareHouseID,shippingMethod,customerID,vbillsCode,
                batchNo, batchNoValue,wareHouseOutBills,beginDate,endDate,pageNum,pageSize,response);
    }
    @ApiOperation("产品发运记录导出csv")
    @PostMapping("/exportCsvReportDeliveryStatistic")
    @LogC(title = "产品发运记录", businessType = BusinessType.EXPORTCSV)
    public AjaxResult exportCsvReportDeliveryStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String shippingMethod,
            @RequestParam(required = false, defaultValue = "") String customerID,
            @RequestParam(required = false, defaultValue = "") String vbillsCode,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String wareHouseOutBills,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        List<ExportReportDeliveryVo> vos = stoUnitService.exportCsvReportDeliveryStatistic(skuID, wareHouseID, shippingMethod, customerID, vbillsCode,
                batchNo, batchNoValue, wareHouseOutBills, beginDate, endDate, pageNum, pageSize, response);
        try {
            CsvExportUtils.exportToWeb(response, "产品发运记录.csv", vos);
            return AjaxResult.success("导出成功");
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("导出失败");
        }
    }
    /**
     * 入厂总账报表
     *
     * @return
     */
    @GetMapping("/wmsReportReceivingStatistic")
    public R wmsReportReceivingStatistic(
            @RequestParam(required = false, defaultValue = "") String receivingDay,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String releaseDay,
            @RequestParam(required = false, defaultValue = "") String stateID,
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String senderID,
            @RequestParam(required = false, defaultValue = "") String manufacturerID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum, Integer pageSize
            ) {
        return stoUnitService.wmsReportReceivingStatistic(skuClassId,receivingDay,releaseDay,stateID,skuID,senderID,manufacturerID,
                batchNo, batchNoValue,pageNum,pageSize);
    }
    @PostMapping("/exportReportReceivingStatistic")
    @ApiOperation("导出excel接口")
    @LogC(title = "入厂总账", businessType = BusinessType.EXPORTCSV)
    public AjaxResult exportReportReceivingStatistic(
            @RequestParam(required = false, defaultValue = "") String receivingDay,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String releaseDay,
            @RequestParam(required = false, defaultValue = "") String stateID,
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String senderID,
            @RequestParam(required = false, defaultValue = "") String manufacturerID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum,Integer pageSize,
            HttpServletResponse response
    ) {
        return stoUnitService.exportReportReceivingStatistic(skuClassId,receivingDay,releaseDay,stateID,skuID,senderID,manufacturerID,
                batchNo, batchNoValue,pageNum,pageSize,response);
    }
    @ApiOperation("导出pdf接口")
    @PostMapping("/exportPdfReportReceivingStatistic")
    @LogC(title = "入厂总账", businessType = BusinessType.EXPORTPDF)
    public AjaxResult exportPdfReportReceivingStatistic(
            @RequestParam(required = false, defaultValue = "") String receivingDay,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String releaseDay,
            @RequestParam(required = false, defaultValue = "") String stateID,
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String senderID,
            @RequestParam(required = false, defaultValue = "") String manufacturerID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum,Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportPdfReportReceivingStatistic(skuClassId,receivingDay,releaseDay,stateID,skuID,senderID,manufacturerID,
                batchNo, batchNoValue,pageNum,pageSize,response);
    }
    @ApiOperation("导出csv接口")
    @PostMapping("/exportCsvReportReceivingStatistic")
    @LogC(title = "入厂总账", businessType = BusinessType.EXPORTCSV)
    public AjaxResult exportCsvReportReceivingStatistic(
            @RequestParam(required = false, defaultValue = "") String receivingDay,
            @RequestParam(required = false, defaultValue = "") String  skuClassId,
            @RequestParam(required = false, defaultValue = "") String releaseDay,
            @RequestParam(required = false, defaultValue = "") String stateID,
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String senderID,
            @RequestParam(required = false, defaultValue = "") String manufacturerID,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            Integer pageNum,Integer pageSize,
            HttpServletResponse response
            ) {
        List<ExportReportReceivingVo> list = stoUnitService.exportCsvReportReceivingStatistic(skuClassId, receivingDay, releaseDay, stateID, skuID, senderID, manufacturerID,
                batchNo, batchNoValue,pageNum,pageSize, response);
        try {
            CsvExportUtils.exportToWeb(response, "入厂总账.csv", list);
            return AjaxResult.success("导出成功");
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("导出失败");
        }
    }

    @PostMapping("/exportReportBasicStatistic")
    @ApiOperation("导出excel接口")
    @LogC(title = "基础报表", businessType = BusinessType.EXPORT)
    public AjaxResult exportReportBasicStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
    ) {
        return stoUnitService.exportReportBasicStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal,pageNum,pageSize,response);
    }

    @ApiOperation("导出pdf接口")
    @PostMapping("/exportPdfReportBasicStatistic")
    @LogC(title = "基础报表", businessType = BusinessType.EXPORTPDF)
    public AjaxResult exportPdfReportBasicStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportPdfReportBasicStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal,pageNum,pageSize,response);
    }

    @ApiOperation("导出csv接口")
    @PostMapping("/exportCsvReportBasicStatistic")
    @LogC(title = "基础报表", businessType = BusinessType.EXPORTCSV)
    public AjaxResult exportCsvReportBasicStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        List<ExportReportBasicVo> list = stoUnitService.exportCsvReportBasicStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal,pageNum,pageSize,response);
        try {
            CsvExportUtils.exportToWeb(response, "基础报表.csv", list);
            return AjaxResult.error("导出成功");
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("导出失败");
        }
    }
    @PostMapping("/exportReportTurnoverStatistic")
    @ApiOperation("导出excel接口")
    @LogC(title = "周转率、使用率", businessType = BusinessType.EXPORT)
    public AjaxResult exportReportTurnoverStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
    ) {
        return stoUnitService.exportReportTurnoverStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal,pageNum,pageSize,response);
    }

    @ApiOperation("导出pdf接口")
    @PostMapping("/exportPdfReportTurnoverStatistic")
    @LogC(title = "周转率、使用率", businessType = BusinessType.EXPORTPDF)
    public AjaxResult exportPdfReportTurnoverStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        return stoUnitService.exportPdfReportTurnoverStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal,pageNum,pageSize,response);
    }

    @ApiOperation("导出csv接口")
    @PostMapping("/exportCsvReportTurnoverStatistic")
    @LogC(title = "周转率、使用率", businessType = BusinessType.EXPORTCSV)
    public AjaxResult exportCsvReportTurnoverStatistic(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum, Integer pageSize,
            HttpServletResponse response
            ) {
        List<ExportReportTurnoverVo> list = stoUnitService.exportCsvReportTurnoverStatistic(skuID, skuClassId, wareHouseID, openBatchNo, batchNo
                , batchNoValue, beginDate, endDate, turnoverRateMinVal, turnoverRateMaxVal, turnoverDay, turnoverDayValue, skuRateMinVal, skuRateMaxVal, pageNum, pageSize, response);
        try {
            CsvExportUtils.exportToWeb(response, "周转率.csv", list);
            return AjaxResult.error("导出成功");
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("导出失败");
        }
    }

    @GetMapping("/wmsOnYearAndChainReport")
    public R wmsOnYearAndChainReport(
            @RequestParam(required = false, defaultValue = "") String skuID,
            @RequestParam(required = false, defaultValue = "") String skuClassId,
            @RequestParam(required = false, defaultValue = "") String wareHouseID,
            @RequestParam(required = false, defaultValue = "") String openBatchNo,
            @RequestParam(required = false, defaultValue = "") String batchNo,
            @RequestParam(required = false, defaultValue = "") String batchNoValue,
            @RequestParam(required = false, defaultValue = "") String beginDate,
            @RequestParam(required = false, defaultValue = "") String endDate,
            @RequestParam(required = false, defaultValue = "") String beginDate1,
            @RequestParam(required = false, defaultValue = "") String endDate1,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMinVal,
            @RequestParam(required = false, defaultValue = "") String turnoverRateMaxVal,
            @RequestParam(required = false, defaultValue = "") String turnoverDay,
            @RequestParam(required = false, defaultValue = "") String turnoverDayValue,
            @RequestParam(required = false, defaultValue = "") String skuRateMinVal,
            @RequestParam(required = false, defaultValue = "") String skuRateMaxVal,
            Integer pageNum,Integer pageSize
    ) {
        return stoUnitService.wmsOnYearAndChainReport(skuID, skuClassId, wareHouseID, openBatchNo,
                batchNo,batchNoValue,beginDate,endDate,turnoverRateMinVal,turnoverRateMaxVal,
                turnoverDay,turnoverDayValue,skuRateMinVal,skuRateMaxVal,beginDate1,endDate1);
    }

    @GetMapping("/wmsInventoryCountReport")
    public R wmsInventoryCountReport(
            String inventoryID, String warehouseId,
            Integer pageNum, Integer pageSize
    ) {
        return stoUnitService.wmsInventoryCountReport(inventoryID, warehouseId, pageNum, pageSize);
    }

}
